#include <graphics/ImageManager.h>

namespace ne
{
    template<> ImageManager* Singleton<ImageManager>::mpInstance = 0;

    ImageManager::ImageManager()
    {
        mResourceType = "Image";
        std::cout << "Construct Image Manager\n";
    }

    ImagePtr ImageManager::createImage(const std::string &name,
                                       const std::string &fileName,
                                       const uint32_t width,
                                       const uint32_t height,
                                       const uint32_t depth,
                                       const PixelFormat format,
                                       const PixelType pt)
    {
        ImagePtr pImage(create(name, fileName, true));
        if (pImage.notNull())
        {
            pImage->createInternalImage(width, height, depth, format, pt);
            pImage->load();
        }
        return pImage;
    }
   
    ImageManager::~ImageManager()
    {
        std::cout << "Disconstruct Image Manager\n";
    }

    ImageManager& ImageManager::GetSingleton()
    {
        assert(mpInstance);
        return *mpInstance;
    }

    ImageManager* ImageManager::GetSingletonPtr()
    {
        return mpInstance;
    }

    Resource* ImageManager::createImplement(const uint64_t id,
                                            const std::string &name,
                                            const std::string &fileName,
                                            const bool isManual,
                                            ManualResourceLoader *pLoader)
    {
        return new Image(this, id, name, fileName, isManual, pLoader);
    }
}
